package com.yebxxx.server.controller;


import com.yebxxx.server.pojo.*;
import com.yebxxx.server.service.IEmployeeTrainService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author stx
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/personnel/train/")
public class EmployeeTrainController {

@Autowired
private IEmployeeTrainService employeeTrainService;
@ApiOperation(value = "员工培训列表")
@GetMapping("/train")
public PageBean getTrainList(@RequestParam(defaultValue = "1" )Integer currentPage,
                             @RequestParam(defaultValue = "10")Integer size,
                             EmployeeTrain employeeTrain, Teacher teacher) {
       return employeeTrainService.getTrainList(currentPage,size,employeeTrain,teacher);
    }
@ApiOperation(value = "添加培训信息")
@PostMapping("/")
public RespBean addTrain(@RequestBody EmployeeTrain employeeTrain){
   if(employeeTrainService.save(employeeTrain)){
       return  RespBean.success("添加成功！");
   }
   return  RespBean.error("添加失败！");
}

    @ApiOperation(value = "删除培训信息")
    @DeleteMapping("/{id}")
    public RespBean  deleteTrain(@PathVariable Integer id){
        if(employeeTrainService.removeById(id)){
            return  RespBean.success("删除成功！");
        }
        return  RespBean.error("删除失败！");
    }
    @ApiOperation(value = "修改培训信息")
    @PutMapping("/{id}")
    public RespBean  updateTrain(@RequestBody EmployeeTrain employeeTrain){
        if(employeeTrainService.updateById(employeeTrain)){
            return  RespBean.success("修改成功！");
        }
        return  RespBean.error("修改失败！");
    } 

}
